import data from "@/views/pdf/content"
import { option1Data } from "@/views/stationsAnalysis/four/assets/echarts"
import axios from "axios"
//引入Vue核心库
import Vue from 'vue'
//引入Vuex
import Vuex from 'vuex'
import http from "@/views/stationsAnalysis/api/request"
//引用Vuex
Vue.use(Vuex)

// 日期
// let data = ['07/16', '07/17', '07/18', '07/19', '07/20', '07/22']
export default {
    namespaced: true,
    actions: {
        askData(context, value) {
           http.get('/').then(res => {
                // console.log(res);
                context.commit('ASKDATA',res.data.list)
            })
      }
    },

    mutations: {
        ASKDATA(state, value) {
            console.log("执行了一次");
            // 日期
            const newRq = value.map(obj => obj.rq[5]+obj.rq[6]+'/'+obj.rq[8]+obj.rq[9])
            
            //数据
            const cyel = value.map(obj => obj.cyel)
            // console.log(state);

            // 改变日期
           Object.keys(state).forEach(key => {
            if (key.startsWith('option') && state[key].xAxis) {
                state[key].xAxis.data = newRq;
            }
});

            // 改变数据
            state.option1Data.series[0].data = cyel
            state.data = value
        }
    },
     getters : {
	   
    },

    state: {
        data:null,
        option1Data: {
                color: ['#5087ec', '#85d0dc', '#70b07a', '#f2bd42'],
                title: {
                    top: 10,
                    left: 10,
                    text: '1号稠油联合处理站',
                    textStyle: {
                        color: '#6DA7F0',
                        fontSize: 17
                    }
                },
                
                // dataZoom: {
                //     type: 'slider',
                //     show: true,
                //     startValue: 0,
                //     endValue: 7,
                //     xAxisIndex: [0]
                // },
                xAxis: {
                    axisLabel: {
                        color: '#fff'
                    },
                    data: ['07/16', '07/17', '07/18', '07/19', '07/20', '07/21']
                },
                series: [
                    {
                        name: '常规正相浓度',
                        type: 'line',
                        data: [60, 80, 88, 90, 96, 90],
                        label: {
                            show: true,
                            color: '#5087ec'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: '常规反相浓度',
                        type: 'line',
                        data: [60, 61, 60, 65, 66, 58],
                        label: {
                            show: true,
                            color: '#85d0dc'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: 'SAGD预处理剂浓度',
                        type: 'line',
                        data: [102, 102, 100, 100, 106, 100],
                        label: {
                            show: true,
                            color: '#70b07a'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: 'SAGD正相浓度',
                        type: 'line',
                        data: [112, 132, 140, 120, 136, 140],
                        label: {
                            show: true,
                            color: '#f2bd42'
                            // formatter: '{c} %'
                        }
                    }
                ]
        },
        option2Data: {
                color: ['#5087ec', '#85d0dc', '#70b07a', '#f2bd42'],
            title: {
                    top: 10,
                    left: 10,
                    text: '2号稠油联合处理站',
                    textStyle: {
                        color: '#6DA7F0',
                        fontSize: 17
                    }
            },
              xAxis: {
                    axisLabel: {
                        color: '#fff'
                    },
                    data: ['07/16', '07/17', '07/18', '07/19', '07/20', '07/21']
            },
                series: [
                    {
                        name: '常规正相浓度',
                        type: 'line',
                        data: [60, 80, 88, 90, 96, 90],
                        label: {
                            show: true,
                            color: '#5087ec'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: '常规反相浓度',
                        type: 'line',
                        data: [60, 61, 60, 65, 66, 58],
                        label: {
                            show: true,
                            color: '#85d0dc'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: 'SAGD预处理剂浓度',
                        type: 'line',
                        data: [102, 102, 100, 100, 106, 100],
                        label: {
                            show: true,
                            color: '#70b07a'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: 'SAGD正相浓度',
                        type: 'line',
                        data: [112, 132, 140, 120, 136, 140],
                        label: {
                            show: true,
                            color: '#f2bd42'
                            // formatter: '{c} %'
                        }
                    }
                ]
        },
        option3Data: {
                color: ['#5087ec', '#85d0dc', '#70b07a', '#f2bd42'],
           title: {
                    top: 10,
                    left: 10,
                    text: '2号稠油联合处理站',
                    textStyle: {
                        color: '#6DA7F0',
                        fontSize: 17
                    }
                },
              xAxis: {
                    axisLabel: {
                        color: '#fff'
                    },
                    data: ['07/16', '07/17', '07/18', '07/19', '07/20', '07/21']
            },
                series: [
                    {
                        name: '常规正相浓度',
                        type: 'line',
                        data: [60, 80, 88, 90, 96, 90],
                        label: {
                            show: true,
                            color: '#5087ec'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: '常规反相浓度',
                        type: 'line',
                        data: [60, 61, 60, 65, 66, 58],
                        label: {
                            show: true,
                            color: '#85d0dc'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: 'SAGD预处理剂浓度',
                        type: 'line',
                        data: [102, 102, 100, 100, 106, 100],
                        label: {
                            show: true,
                            color: '#70b07a'
                            // formatter: '{c} %'
                        }
                    },
                    {
                        name: 'SAGD正相浓度',
                        type: 'line',
                        data: [112, 132, 140, 120, 136, 140],
                        label: {
                            show: true,
                            color: '#f2bd42'
                            // formatter: '{c} %'
                        }
                    }
                ]
        },
        option4Data: {
                color: ['#f2bd42'],
                title: {
                    top: 20,
                    left: 10,
                    text: '处理气量',
                    textStyle: {
                        color: '#6DA7F0',
                        fontSize: 17
                    }
                },
                xAxis: {
                    axisLabel: {
                        color: '#fff'
                    },
                    data: ['07/16', '07/17', '07/18', '07/19', '07/20', '07/21']
            },
                 series: [
                    {
                        name: '处理气量',
                        type: 'line',
                        data: [54000, 53000, 52000, 54123, 56128, 55520],
                        label: {
                            show: true,
                            color: '#f2bd42'
                        }
                    }
                ]
        },
        option5Data: {
                color: ['#a2ef4d'],
                title: {
                    top: 20,
                    left: 10,
                    text: '收硫膏量',
                    textStyle: {
                        color: '#6DA7F0',
                        fontSize: 17
                    }
            },
                xAxis: {
                    axisLabel: {
                        color: '#fff'
                    },
                    data: ['07/16', '07/17', '07/18', '07/19', '07/20', '07/21']
            },
                series: [
                    {
                        name: '收硫膏量',
                        type: 'line',
                        data: [54000, 53000, 52000, 54123, 56128, 55520],
                        label: {
                            show: true,
                            color: '#a2ef4d'
                        }
                    }
                ]
        },
        option6Data: {
                color: ['#75f9fd'],
                title: {
                    top: 20,
                    left: 10,
                    text: '净化气量',
                    textStyle: {
                        color: '#6DA7F0',
                        fontSize: 17
                    }
            },
                xAxis: {
                    axisLabel: {
                        color: '#fff'
                    },
                    data: ['07/16', '07/17', '07/18', '07/19', '07/20', '07/21']
            },
                series: [
                    {
                        name: '净化气量',
                        type: 'line',
                        data: [54000, 53000, 52000, 54123, 56128, 55520],
                        label: {
                            show: true,
                            color: '#75f9fd'
                        }
                    }
                ]
        },
        option7Data: {
                color: ['#5087ec'],
                title: {
                    top: 20,
                    left: 10,
                    text: '二氧化碳外输量',
                    textStyle: {
                        color: '#6DA7F0',
                        fontSize: 17
                    }
            }, 
                 xAxis: {
                    axisLabel: {
                        color: '#fff'
                    },
                    data: ['07/16', '07/17', '07/18', '07/19', '07/20', '07/21']
            },
                  series: [
                    {
                        name: '二氧化碳外输量',
                        type: 'line',
                        data: [54000, 53000, 52000, 54123, 56128, 55520],
                        label: {
                            show: true,
                            color: '#5087ec'
                        }
                    }
                ]
        }
    }
}

 
